import Request from "@/sdk/pocky-request/index.js"; //引入
/**
 * teacher store
 */
const teacher = {
    // 状态
    state: {

    },
    // 内部派生
    getters: {

    },
    // 同步方法 commit
    mutations: {

    },
    // 异步方法 dispatch
    actions: {
		/**
		 * 获取教师列表
		 * @param {Object} context
		 * @param {Object} _data
		 */
		apiGetTeacherList(context,_data){
			return new Promise((resolve,reject)=>{
				Request().request({
					url:'/store/teacher/list.do',
					method:'post',
					data:_data
				}).then(res=>{
					if(res.data.result==1){
						resolve(res)
						
					}else{
						uni.showToast({
							title: '获取教师列表失败,'+res.data.msg,
							icon: 'none'
						});
						reject(res)
					}
				}).catch(err=>{
					uni.showToast({
						title: '获取教师列表失败,'+res.data.msg,
						icon: 'none'
					});
					reject(res)
				})
			})
		},
		apiGetTeacherDt(context,_data){
			return new Promise((resolve,reject)=>{
				Request().request({
					url:'/store/teacher/detail.do',
					method:'post',
					data:_data
				}).then(res=>{
					if(res.data.code==1){
						resolve(res)
						
					}else{
						uni.showToast({
							title: '获取教师详情失败,'+res.data.msg,
							icon: 'none'
						});
						reject(res)
					}
				}).catch(err=>{
					uni.showToast({
						title: '获取教师详情失败,'+res.data.msg,
						icon: 'none'
					});
					reject(res)
				})
			})
		}
    }
}

export default teacher
